package org.gpswalker.sys.server.components;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jdom.output.XMLOutputter;

public class SVGServlet extends HttpServlet {

    public void service(HttpServletRequest req, HttpServletResponse res) {

	SVG sv = new SVG(600, 600);

	sv.circle(new Point(0.0, 300.0), 15);

	double whies[] = { 3.0, 45.37, 84.1763, 34.8, 371.947, 82.0 };
	sv.setColor(0xffaa77);

	sv.linearGraph(whies);
	
	PrintWriter out = null;
	// res.setContentType(arg0)
	try {
	    out = res.getWriter();
	} catch (IOException e1) {
	    // TODO Auto-generated catch block
	    e1.printStackTrace();
	}

	XMLOutputter outputter = new XMLOutputter();
	try {
	    outputter.output(sv.doc(), out);
	} catch (IOException e) {
	    System.err.println(e);
	}

    }

}
